<!-- InstanceBegin template="/Templates/admin-template.dwt.php" codeOutsideHTMLIsLocked="false" --><!DOCTYPE html>

<!--[if IE 7 ]>   <html lang="en" class="ie7 lte8"> <![endif]--> 

<!--[if IE 8 ]>   <html lang="en" class="ie8 lte8"> <![endif]--> 

<!--[if IE 9 ]>   <html lang="en" class="ie9"> <![endif]--> 

<!--[if gt IE 9]> <html lang="en"> <![endif]-->

<!--[if !IE]><!--> <html lang="en"> <!--<![endif]--><head>

<?php 

	include_once("CheckSession.php");

?>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<!--[if lte IE 9 ]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><![endif]-->



<!-- iPad Settings -->

<meta name="apple-mobile-web-app-capable" content="yes" />

<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> 

<meta name="viewport" content="user-scalable=no, initial-scale=1.0, width=device-width ">

<!-- iPad End -->

<!-- InstanceBeginEditable name="doctitle" -->
<title>Sửa sản phẩm | Quang Du Co</title>
<!-- InstanceEndEditable -->

<link rel="shortcut icon" href="favicon.ico">



<!-- iOS ICONS -->

<link rel="apple-touch-icon" href="touch-icon-iphone.png" />

<link rel="apple-touch-icon" sizes="72x72" href="touch-icon-ipad.png" />

<link rel="apple-touch-icon" sizes="114x114" href="touch-icon-iphone4.png" />

<link rel="apple-touch-startup-image" href="touch-startup-image.png">

<!-- iOS ICONS END -->



<!-- STYLESHEETS -->

<!-- InstanceBeginEditable name="CSS" -->
<link rel="stylesheet" media="screen" href="css/forms.css" />
<!-- InstanceEndEditable -->



<link rel="stylesheet" media="screen" href="css/reset.css" />

<link rel="stylesheet" media="screen" href="css/grids.css" />

<link rel="stylesheet" media="screen" href="css/style.css" />

<link rel="stylesheet" media="screen" href="css/jquery.uniform.css" />

<link rel="stylesheet" media="screen" href="css/themes/lightblue/style.css" />



<!-- jQplot CSS -->

<link rel="stylesheet" media="screen" href="lib/jqplot/jquery.jqplot.min.css" />

<!-- jQplot CSS END -->



<style type = "text/css">

    #loading-container {position: absolute; top:50%; left:50%;}

    #loading-content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}

    #loading-content {font-family: "Helvetica", "Arial", sans-serif; font-size: 18px; color: black; text-shadow: 0px 1px 0px white; }

    #loading-graphic {margin-right: 0.2em; margin-bottom:-2px;}

    #loading {background-color: #eeeeee; height:100%; width:100%; overflow:hidden; position: absolute; left: 0; top: 0; z-index: 99999;}

</style>



<!-- STYLESHEETS END -->



<!--[if lt IE 9]>

<script src="js/html5.js"></script>

<script type="text/javascript" src="js/selectivizr.js"></script>

<![endif]-->



<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->

</head>

<body style='overflow: hidden;'>

    

  <div id="loading"> 



        <script type = "text/javascript"> 

            document.write('<div id="loading-container"><p id="loading-content">' +

                           "<img id='loading-graphic' width='16' height='16' src='images/ajax-loader-eeeeee.gif' /> " +

                           

						   'Loading...</p></div>');

        </script>

    </div> 



    <div id="wrapper">

        <header>

            <h1><a href="#">Quản lý Quang Du</a></h1>

            <nav>

				<ul id="main-navigation" class="clearfix"> 

                    <li class="fr dropdown"> 

                        <a href="#" class="with-profile-image"><span><img src="images/profile-image.png" /></span>Administrator</a> 

                        <ul> 

                            <li><a href="DoiMatKhau.php">Đổi mật khẩu</a></li> 
                            <li><a href="logout.php">Thoát</a></li> 

                        </ul>

                    </li> 

				</ul> 

            </nav>

            

        </header>

        

        <section>

            <!-- Sidebar -->



            <aside>

                <nav>

                    <ul>

                        <li class="current"><a href="ThemSanPham.php">Thêm sản phẩm</a></li>

                        <li><a href="QuanLySanPham.php">Quản lý sản phẩm</a></li>
                        
                        <li><a href="QuanLyThongTin.php">Quản Lý thông tin</a></li>

                    </ul>

                </nav>
                
            </aside>



            <!-- Sidebar End --><!-- InstanceBeginEditable name="main section" -->
            <section>
              <header class="container_12 clearfix">
                <div class="grid_12">
                  <h1>Sửa sản phẩm</h1>
                </div>
              </header>
              <section class="container_12 clearfix">
                <div class="portlet grid_12">
                  <header>
                    <h2>Sửa sản phẩm trong Shop</h2>
                  </header>
                  <section>
				  	<?php
						//nếu tồn tai Get id
						if(isset($_GET["id"]))
						{
							$MaSanPham = $_GET["id"];
							
							//Lấy 1 sản phẩm
							include_once("lib/ClassSanPham.php");
							include_once("lib/ClassHinh.php");
							
							$sp = new SanPham;
							$sp = SanPham::LaySanPham_ChuaXoa_TheoMa($MaSanPham);
							if($sp)
							{
								//echo ra phần sửa sản phẩm
                            	echo '
								<form class="form has-validation" action="xlSuaSanPham.php" method="POST" enctype="multipart/form-data">
								  <input name="Id" type="hidden" value="'.$_GET['id'].'">
								  <div class="clearfix">
									<label for="form-name" class="form-label" >Tên sản phẩm <em>*</em><small>Nhập vào tên sản phẩm</small></label>
									<div class="form-input">
									  <input type="text" id="form-name" name="TenSanPham" required="required" value="'.$sp->TenSanPham.'" />
									</div>
								  </div>                   
								  <div class="clearfix">
									<label for="form-name" class="form-label" >Thông tin <small>Thông tin của khách hàng</small></label>
									<div class="form-input">
									  <textarea id="elm1" name="ThongTin" cols="20" rows="10" style="width:100%" class="tinymce">'.$sp->ThongTin.'</textarea>
									
								  </div>  
								  <div class="clearfix">
								 	<label for="form-name" class="form-label" >Hình ảnh của sản phẩm <small>Tất cả hình ảnh của sản phẩm</small></label>
									<div class="form-input">';
									$Arr_Img = HinhAnh::LayDanhSachHinh_ChuaXoa_TheoMaSanPham($sp->MaSanPham);
									foreach($Arr_Img as $img)
									{
										echo '<INPUT TYPE=RADIO NAME="Img" VALUE="'.$img->Url.'">
												<ul id="media" class="display-inline leading clearfix" style="margin-left: 20px;
margin-top:-40px;"><li class="architecture isotope-item"> 
											<a href="#" rel="#overlay">
											<img src="'.$img->Url.'" height="100" width="150" /><BR></a></li></ul>';
									}
								echo ' </div>
								  </div>
								  <div class="clearfix">
								  	<label for="form-name" class="form-label">Up lại hình ?<small>Bạn có muốn up lại hình hay không ?</small></label>
                                    <div class="form-input">
										<input name="UpLaiHinh" type="radio" value="true"> Up lại hình <br/>
										<input name="UpLaiHinh" type="radio" value="false" checked > Không Up lại hình <br/>
									</div>
								  </div>
								  <div id="HinhUpload">                                                                                         
									  <div class="img">                        
										<div class="clearfix">
										  <label for="form-upload" class="form-label">Hình ảnh <em>*</em><small>Kích thước tùy ý, định dạng jpeg/png </small></label>
										  <div class="form-input">
											<input type="file" name="HinhAnh1" id="form-upload" required="required" />
										  </div>
										</div>
									  </div>
								  </div>                      
								  <div class="form-action clearfix">
									 <input type="hidden" id="SoLuongHinh" name="SoLuongHinh" value="1">
									<button class="button" type="submit" data-icon-primary="ui-icon-circle-check">OK</button>
									<button class="button" type="reset">Reset</button>
								  </div>
								</form>

								 <div class="clearfix">
                                    <input name="" type="button" class="button" id="AddMorePhoto" data-icon-primary="ui-icon-circle-check" value="Thêm hình" >
                                </div>
								
								</section>
                  
								</div>
							  </section>
								';
							}
							//không tìm dc sản phẩm mặc gù có get id
							else
							{
								echo 'Không tìm thấy sản phẩm trong cơ sở dữ liệu';
							}
						}
                        //else nếu id ko có thật
                        else
                        {
                            echo 'Xảy ra lỗi, vui lòng thử lại sau';
                        }			
					?>
                    
                    
                                                   
			<!-- InstanceEndEditable -->

            

            



            <!-- Main Section End -->

				<footer class="container_12 clearfix">

                    <div class="grid_12">

                        Make by <span style="color:#09F";>Impossible Team</span>

                    </div>

                </footer>

            </section>

    </div>

    

    <!-- MAIN JAVASCRIPTS -->

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.js"></script>

    <script>window.jQuery || document.write("<script src='js/jquery.min.js'>\x3C/script>")</script>

    <script type="text/javascript" src="js/jquery.tools.min.js"></script>

    <script type="text/javascript" src="js/jquery.uniform.min.js"></script>

    <!--[if lt IE 9]>

    <script type="text/javascript" src="js/PIE.js"></script>

    <script type="text/javascript" src="js/ie.js"></script>

    <![endif]-->



    <script type="text/javascript" src="js/global.js"></script>

    <!-- MAIN JAVASCRIPTS END -->



    <!-- LOADING SCRIPT -->

    <script>

    $(window).load(function(){

        $("#loading").fadeOut(function(){

            $(this).remove();

            $('body').removeAttr('style');

        });

    });

    </script>

    <!-- LOADING SCRIPT -->

    

    <!-- jQplot SETUP -->

    <!--[if lt IE 9]>

    <script type="text/javascript" src="lib/jqplot/excanvas.js"></script>

    <![endif]--><!-- InstanceBeginEditable name="Script" -->
	<script>
    $(function(){
		$PhotoNumber = 1;
		$('#AddMorePhoto').live('click',function(){
				$PhotoNumber++;
				$newdiv1 = "<div class='clearfix'> <label for='form-upload' class='form-label'>Hình ảnh<em>*</em><small>Kích thước tùy ý, định dạng jpeg/png </small></label><div class='form-input'><input type='file' id='form-upload' class ='new' name='HinhAnh" + $PhotoNumber + "' required='required'/></div></div>";
				$(".img:last").append($newdiv1);
				$(".new").uniform();
				$(".new").removeClass("new");
				$('input[name*="SoLuongHinh"]').val($PhotoNumber);
			});
		//Không hiển thị thanh upload hình 
		$("#HinhUpload").css("display","none");
		$("input:file").removeAttr("required");
		//nếu chọn upload lại hình thi hiển thị
		//và nếu lại bỏ chọn thì lại xóa đi
		$("input[name='UpLaiHinh']").change(function(){
			if ($("input[name='UpLaiHinh']:checked").val() == 'true') {
				$("#HinhUpload").css("display","block");
				$("#form-upload:nth-child(1)").attr('required','required');
			}
			else{
				$("#HinhUpload").css('display','none');
				$("input:file").removeAttr('required');
			}
		});
	});
    </script> 
	<script>
        $(":date").dateinput({format: 'yyyy-mm-dd'});
		
		//Ẩn và hiện thi upload hình
		
    </script>
    <script type="text/javascript" src="js/jquery.isotope.min.js"></script>
    <script type="text/javascript">
    $.tools.overlay.addEffect("popup",
    
        function(position, done) {
            var overlay = this.getOverlay();
            // compute position
            var top = $(window).height()/2 - 26;
            var left = $(window).width()/2 - 26;
            overlay.addClass('loading')
                .width(32).height(32)
                .css({top: top + 'px', left: left + 'px', display: 'block', opacity: 1})
                .data('oleft', left).data('otop', top)
        },
        // close function
        function(done) {
            var overlay = this.getOverlay();
            overlay.stop().removeClass('loading').animate({opacity: 0, width: 32, height: 32, left: overlay.data('oleft'), top: overlay.data('otop')}, this.getConf().closeSpeed, 'swing', done);
        }
    );
    $(window).load(function(){
        $('#media').isotope({
            // options
            itemSelector : 'li'
        });
        $('#filters a').click(function(){
            var selector = $(this).attr('data-filter');
            $('#media').isotope({ filter: selector });
            $(this).parent().addClass('current').siblings().removeClass('current');
            return false;
        });
        
        $("a[rel]").overlay({
            effect: 'popup',
            mask: '#ffffff',
            left: 'center',
            top: 'center',
            onBeforeLoad: function() {
                var overlay = this.getOverlay();
                // grab img element inside content
                var img = overlay.find("img").fadeOut();
                var tmp = $('<img />');
                // load the img specified in the trigger
                img.unbind().width(0).height(0).attr('src', '').css('visibility', 'hidden');
                tmp.attr('src', this.getTrigger().attr("href")).load(function(){
                    if (overlay.hasClass('loading')) {
                        overlay.animate({opacity: 1, width: this.width, height: this.height, left: $(window).width()/2 - this.width/2 - 10, top: 50}, 'slow', 'swing', function(){
                            overlay.removeClass('loading').css('overflow', 'visible');
                        });
                        img.replaceWith(tmp.css({visibility: 'visible', opacity: 0, width: '100%', height: '100%'}).animate({opacity:1},2000,'swing'));
                    }
                });
            },
            onBeforeClose: function() {
                this.getOverlay().addClass('closing').find("img").unbind();
            },
            onClose: function() {
                this.getOverlay().removeClass('closing');
            }
        });
    });
    </script>
	<!-- InstanceEndEditable --> 

<script type="text/javascript" src="lib/jqplot/jquery.jqplot.min.js"></script>

    <script type="text/javascript" src="lib/jqplot/plugins/jqplot.categoryAxisRenderer.min.js"></script>

    <script type="text/javascript" src="lib/jqplot/plugins/jqplot.barRenderer.min.js"></script>

    <script type="text/javascript">

    $(document).ready(function(){

        var line1 = [1,4, 9, 16];

        var line2 = [25, 12.5, 6.25, 3.125];

        var line3 = [2, 7, 15, 30];

        var plot2 = $.jqplot('chart2', [line1, line2, line3], {

            show: true,

            legend:{show:true, location:'ne', xoffset:0},

            seriesDefaults:{

                renderer:$.jqplot.BarRenderer, 

                rendererOptions:{barPadding: 8, barMargin: 10, shadowDepth: 2}

            },

            series:[

                {label:'Profits'}, 

                {label:'Expenses'}, 

                {label:'Sales'}

            ],

            axes:{

                xaxis:{

                    renderer:$.jqplot.CategoryAxisRenderer, 

                    ticks:['1st Qtr', '2nd Qtr', '3rd Qtr', '4th Qtr']

                }, 

                yaxis:{min:0}

            }

        });

    });

    </script>

    <!-- jQplot SETUP END -->

</body>

<!-- InstanceEnd --></html>

